import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import qiankun from 'vite-plugin-qiankun'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // 在开发模式下需要把react()关掉
    // react(),
    //@ts-ignore
    qiankun('sub-react', { useDevMode: true }),
  ],
  base: process.env.NODE_ENV === 'development' ? '/' : 'http://115.190.202.175/reactComponent', // 强制设置
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
  resolve: {
    // 路径别名
    alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
  },
  build: {
    outDir: 'dist_reactComponent',
  },
  server: {
    // 热更新
    hmr: true,
    // 打开端口
    port: 7036,
  },
})
